//
//  ALNetWorkTool.swift
//  ALSinaWeiBoSwift
//
//  Created by 柴瑞军 on 16/4/10.
//  Copyright © 2016年 myCompany. All rights reserved.
//

import AFNetworking

enum ALNetworkError: Int {
    case accessTokenEmpty = -1
    case uidEmpty = -2
    
    var errorDescription: String {
        get{
            switch self {
            case accessTokenEmpty:
                return "accessTokenEmpty"
            case uidEmpty:
                return "usdEmpty"
            }
        }
    }
    
    //        枚举中定义方法--返回错误
    func error() -> NSError {
        return NSError(domain: "cn.itheima.net", code: self.rawValue, userInfo: ["errorDescription" : self.errorDescription])
    }
    
}
class ALNetWorkTool: AFHTTPSessionManager {
    
    
//    static修饰的属性不会销毁,直到程序退出的时候属性才会销毁
//    let 定义的常量属性只能创建一次,或者说属性只能进行一次赋值
//    要指定单例的累类型
    static let shareInstance: ALNetWorkTool = {
        let netWorking = ALNetWorkTool()
        
        netWorking.responseSerializer.acceptableContentTypes?.insert("text/plain")
        return netWorking
    }()
    
}
